﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
using Word.Editor.Doc;

namespace Word.Editor
{
    public partial class WordControl : UserControl
    {
        public DocFileStream document = null;
        public WordControl()
        {
            InitializeComponent();

            List<RibbonItem> FontList = new List<RibbonItem>();
            foreach (FontFamily ff in FontFamily.Families)
                FontList.Add(new RibbonButton(ff.Name));
            FontTypeComboBox.DropDownItems.AddRange(FontList);

            //Load images for icons from resx
            Image folderImage = (Image)Properties.Resources.ResourceManager.GetObject("storage");
            Image streamImage = (Image)Properties.Resources.ResourceManager.GetObject("stream");

            StructureTV.ImageList = new ImageList();
            StructureTV.ImageList.Images.Add(folderImage);
            StructureTV.ImageList.Images.Add(streamImage);
        }

        private void ribbonOrbMenuItem1_Click(object sender, EventArgs e)
        {
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    document = new DocFileStream(StructureTV);
                    document.Open(openFileDialog.FileName, System.IO.FileMode.Open);
                }
                catch(Exception ex)
                {
                    richTextBoxControl.Text += ex.ToString();
                }
                //String ret = String.Format("{0:x},{1:x}", document._sFib.wIdent, document._sfibRgFcLcb.fcClx);
                richTextBoxControl.Text = document.msg;
                document.Close();
            }
        }

        private void ExitOptionButton_Click(object sender, EventArgs e)
        {
            if (Parent != null)
            {
                ((Form)Parent).Close();
            }
        }

        private void ribbonOrbMenuItem2_Click(object sender, EventArgs e)
        {
            richTextBoxControl.Visible = !ViewStructureOMI.Checked;
            StructureTV.Visible = ViewStructureOMI.Checked;
        }

    }
}
